<?php
header('Content-type:text/html;charset=utf-8');

//包含数据库配置
include '../../public/peizhi.php';

//包含函数
include '../../public/func.php';

//调用函数
$link = db();

//接值准备SQL语句
if(!empty($_REQUEST['bk_id'])){
	$bk_id = $_REQUEST['bk_id'];
		if(is_array($bk_id)){
			$bkid = implode(',',$bk_id);
		}else{
			$bkid = $bk_id;
		}
		//查询板块里是否有主贴
		$lsql = "select id from fatie where bk_id in({$bkid})";
		$lres = mysqli_query($link,$lsql);
			if($lres && mysqli_num_rows($lres)){
				exit('<script>alert("该板块下有主贴,不能被删除");window.location.href="show.php";</script>');
			}else{
					$sql = "delete from bankuai where bk_id in({$bkid})";
				}
}else{
	exit('<script>alert("没有板块或没有选择板块");window.location.href="show.php";</script>');
}

//执行SQL语句
if($res = mysqli_query($link,$sql)){
	echo '<script>alert("删除板块成功");window.location.href="show.php";</script>';
}else{
	echo '<script>alert("删除板块失败");window.location.href="show.php";</script>';
}

//释放结果
mysqli_free_result($lres);

//关闭数据库连接
mysqli_close($link);

